home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / ewl / examples / ewl_imenu_test.c < prev    next >
C/C++ Source or Header  |  2006-01-09  |  4KB  |  125 lines

  1. #include "ewl_test.h"
  2.  
  3. static Ewl_Widget *imenu_button = NULL;
  4.  
  5. static void
  6. __destroy_imenu_test_window(Ewl_Widget * w, void *ev_data __UNUSED__, 
  7.                         void *user_data __UNUSED__)
  8. {
  9.     ewl_widget_destroy(w);
  10.     ewl_callback_append(imenu_button, EWL_CALLBACK_CLICKED,
  11.                 __create_imenu_test_window, NULL);
  12. }
  13.  
  14. static void
  15. __imenu_focus_in(Ewl_Widget * w, void *ev_data __UNUSED__, 
  16.                 void *user_data __UNUSED__)
  17. {
  18.     char *text;
  19.  
  20.     text = ewl_text_text_get(EWL_TEXT(EWL_MENU_ITEM(w)->text));
  21.     printf("%s item down\n", text);
  22. }
  23.  
  24. static void
  25. __imenu_configure(Ewl_Widget * w, void *ev_data __UNUSED__,
  26.                 void *user_data __UNUSED__)
  27. {
  28.     printf("Imenu configured to (%d, %d) %dx%d\n", CURRENT_X(w),
  29.             CURRENT_Y(w), CURRENT_W(w), CURRENT_H(w));
  30. }
  31.  
  32. void
  33. __create_imenu_test_window(Ewl_Widget * w, void *ev_data __UNUSED__,
  34.                     void *user_data __UNUSED__)
  35. {
  36.     Ewl_Widget     *imenu_win;
  37.     Ewl_Widget     *imenu_box;
  38.     Ewl_Widget     *imenu1, *imenu2;
  39.     Ewl_Widget     *item;
  40.  
  41.     imenu_button = w;
  42.  
  43.     imenu_win = ewl_window_new();
  44.     ewl_window_title_set(EWL_WINDOW(imenu_win), "Imenu Test");
  45.     ewl_window_name_set(EWL_WINDOW(imenu_win), "EWL Test Application");
  46.     ewl_window_class_set(EWL_WINDOW(imenu_win), "EFL Test Application");
  47.  
  48.     if (w) {
  49.         ewl_callback_del(w, EWL_CALLBACK_CLICKED, 
  50.                     __create_imenu_test_window);
  51.         ewl_callback_append(imenu_win, EWL_CALLBACK_DELETE_WINDOW,
  52.                     __destroy_imenu_test_window, NULL);
  53.     } else
  54.         ewl_callback_append(imenu_win, EWL_CALLBACK_DELETE_WINDOW,
  55.                     __close_main_window, NULL);
  56.     ewl_widget_show(imenu_win);
  57.  
  58.     /*
  59.      * Create the main box for holding the widgets
  60.      */
  61.     imenu_box = ewl_vbox_new();
  62.     ewl_object_fill_policy_set(EWL_OBJECT(imenu_box), EWL_FLAG_FILL_FILL);
  63.     ewl_container_child_append(EWL_CONTAINER(imenu_win), imenu_box);
  64.     ewl_widget_show(imenu_box);
  65.  
  66.     /*
  67.      * Create the menu
  68.      */
  69.     imenu1 = ewl_imenu_new();
  70.     ewl_menu_item_text_set(EWL_MENU_ITEM(imenu1), "test menu");
  71.     ewl_object_fill_policy_set(EWL_OBJECT(imenu1), EWL_FLAG_FILL_NONE);
  72.     ewl_container_child_append(EWL_CONTAINER(imenu_box), imenu1);
  73.     ewl_widget_show(imenu1);
  74.  
  75.     /*
  76.      * Append some test items
  77.      */
  78.     item = ewl_menu_item_new();
  79.     ewl_menu_item_image_set(EWL_MENU_ITEM(item), "/usr/share/pixmaps/dia-diagram.png");
  80.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "dia");
  81.     ewl_container_child_append(EWL_CONTAINER(imenu1), item);
  82.     ewl_callback_append(item, EWL_CALLBACK_FOCUS_IN, __imenu_focus_in, NULL);
  83.     ewl_callback_append(item, EWL_CALLBACK_CONFIGURE,
  84.                 __imenu_configure, NULL);
  85.     ewl_widget_show(item);
  86.  
  87.     item = ewl_separator_new();
  88.     ewl_container_child_append(EWL_CONTAINER(imenu1), item);
  89.     ewl_widget_show(item);
  90.  
  91.     item = ewl_menu_item_new();
  92.     ewl_menu_item_image_set(EWL_MENU_ITEM(item), "/usr/share/pixmaps/wilber.png");
  93.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "gimp");
  94.     ewl_container_child_append(EWL_CONTAINER(imenu1), item);
  95.     ewl_callback_append(item, EWL_CALLBACK_FOCUS_IN, __imenu_focus_in, NULL);
  96.     ewl_widget_show(item);
  97.  
  98.     item = ewl_menu_item_new();
  99.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "button");
  100.     ewl_container_child_append(EWL_CONTAINER(imenu1), item);
  101.     ewl_callback_append(item, EWL_CALLBACK_FOCUS_IN, __imenu_focus_in, NULL);
  102.     ewl_widget_show(item);
  103.  
  104.     /*
  105.      * Create a sub-menu
  106.      */
  107.     imenu2 = ewl_imenu_new();
  108.     ewl_menu_item_text_set(EWL_MENU_ITEM(imenu2), "Sub menu");
  109.     ewl_container_child_append(EWL_CONTAINER(imenu1), imenu2);
  110.     ewl_widget_show(imenu2);
  111.  
  112.     item = ewl_menu_item_new();
  113.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "button");
  114.     ewl_container_child_append(EWL_CONTAINER(imenu2), item);
  115.     ewl_callback_append(item, EWL_CALLBACK_FOCUS_IN, __imenu_focus_in, NULL);
  116.     ewl_widget_show(item);
  117.  
  118.     item = ewl_menu_item_new();
  119.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "button");
  120.     ewl_container_child_append(EWL_CONTAINER(imenu2), item);
  121.     ewl_callback_append(item, EWL_CALLBACK_FOCUS_IN, __imenu_focus_in, NULL);
  122.     ewl_widget_show(item);
  123. }
  124.  
  125.